<!--重污染预警响应天数 统计分析-->
<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="120">
            <Row v-show="!switchFlag" class="query-form" >
                <Col span="8">
                    <FormItem label="企业名称：" prop="orgId">
                        <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyId'
                                      :orgTree="true"
                                      :currentOrgId="dataToQuery.companyId"
                                      :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label='年度：' prop='year'>
                        <DatePicker class="query-form-el" placeholder="请选择年度" v-model='dataToQuery.yearDate' type="year"></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8">
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search"  @click="query">查询</Button>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" :row-class-name="rowClassName" no-data-text="没有查询到相关数据!" @on-selection-change = 'getSelectRows' :loading='pageStatus.loading'
               border :columns="columns1"  :data="dataTable" >
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24" >
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
            </Col>
        </Row>
    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    export default {
        name: "performanceRating",
        components:{
            cascaderDom
        },
        data(){
            return {
                ...this.createCommonDataField(),
                columns1: [
                    { title: '序号', width: 80, fixed: 'left', align: 'center', render: (h, params) => {
                            if(params.row.companyName === '汇总') return h('span', "汇总");
                            return h('span', (params.index) + (this.pagedata.currentPage - 1) * this.pagedata.pageSize);
                    }},
                    { key:'companyName',title: '企业名称', fixed: 'left', align: 'center', minWidth: 240,render: (h, params) => {
                            if(params.row.companyName === '汇总') return h('span', "");
                            return h('span', params.row.companyName);
                    } },
                    { key:'year',title: '年度', fixed: 'left', align: 'center', minWidth: 80 },
                    { key:'warningDays',title: '预警天数',  align: 'center', minWidth: 80 },
                    { key:'yellow_warningDays',title: '黄色预警天数',  align: 'center', minWidth: 80 },
                    { key:'orange_warningDays',title: '橙色预警天数',  align: 'center', minWidth: 80 },
                    { key:'red_warningDays',title: '红色预警天数',  align: 'center', minWidth: 80 }
                ],
                tableHeight:10,
                dictMap: {},
                // api
                queryUrl:Api.statisticsHePoWeatherWarningResponse
            }
        },
        async mounted() {
            this.setTableHeight();
            this.query();
        },
        methods:{
            ...pageCommonFunction,
            deleteData(params) {
                this.deleteDateAjax(params);
            },
            rowClassName(row, index) {
                if (row.orgId === '-1') {
                    return 'table-summary-row';
                }
            },
            query() {
                if(!this.dataToQuery.yearDate) {
                    this.dataToQuery.yearDate = new Date();
                }
                this.dataToQuery.year = this.dataToQuery.yearDate.getFullYear();
                this.queryAjax();
            },
            submit(name) {
                if(this.dataToView.rptPeroidDate) {
                    this.dataToView.rptPeroid = this.dataToView.rptPeroidDate.getFullYear();
                }
                this.submitAjax(name);
            },
            async beforeEditDialogOpen(data) {
                data.row.rptPeroidDate = new Date(data.row.rptPeroid + '-01-01');
            },
            createEmptyDataToAdd(){
                return {}
            },
            reset() {
                this.dataToQuery = {};
                this.dataToQuery.yearDate = new Date();
                if (this.$refs.queryOrgCascader) {
                    this.$refs.queryOrgCascader.resetCurrentOrg();
                }
                if (this.$refs.queryOrgCascader1) {
                    this.$refs.queryOrgCascader1.resetCurrentOrg();
                }
            }
        },
        watch:{
        },

    }
</script>

<style lang='css' scoped>
    /deep/ .ivu-table .table-summary-row {
        border-top: 1px solid #e8eaec;
        background-color: #f8f8f9;
    }

    /deep/ .ivu-table .table-summary-row td {
        border-right: 1px solid #e8eaec;
        background-color: #f8f8f9;
    }
</style>
